<script setup>
import {reactive, onMounted} from 'vue'
import servers from '@/utils/request.js'

// const tableData = reactive([]);
//
// onMounted(() => {
//   servers.post('/loginRecords/')
//       .then((response) => {
//         const {data} = response.data;
//         tableData.push(...data);
//       })
//       .catch((error) => {
//         console.error('请求获取登录记录出现错误：', error);
//       });
// });


const tableData = [
  {
    id:1,
    title: '今日热点',
    time: '2024/12/11 14:50',
    filepath: 'No. 189, Grove St, Los Angeles',
  },
]
</script>

<template>
  <div class="box_main">
    <div>网站轮播图预览</div>
    <div class="mt20">
      <el-carousel :interval="4000" type="card" height="200px">
        <el-carousel-item v-for="item in 4" :key="item">
          <h3 text="2xl" justify="center">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="mt20">
      <el-table :data="tableData" style="width: 100%" max-height="250">
        <el-table-column prop="id" label="ID" width="50" />
        <el-table-column prop="title" label="标题" width="200" />
        <el-table-column prop="time" label="更新时间" width="200" />
        <el-table-column prop="filepath" label="文件地址" width="600" />
        <el-table-column fixed="right" label="操作" min-width="120">
          <template #default="scope">
            <el-button type="primary" @click.prevent="deleteRow(scope.$index)">编辑</el-button>
            <el-button type="danger" @click.prevent="deleteRow(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-button class="mt-4" style="width: 100%" @click="onAddItem">
        Add Item
      </el-button>
    </div>
  </div>
</template>

<style scoped>
.mt20 {
  margin-top: 20px;
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>